package com.osexp.model;

import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.List;
import java.io.FileReader;
import java.io.IOException;

public class mappingReader {
	public List<mapping>formatRead(String fileName){
		FileReader in = null;
		BufferedReader read = null;
		String s = null;			

		List<mapping> mappingList=new ArrayList<mapping>();
		try {
			in = new FileReader(fileName);
			read=new BufferedReader(in);
			while ((s = read.readLine()) != null) {	                
	                String[]strings = s.split("\\s");
	                mappingList.add(new mapping(Integer.parseInt(strings[0]),Integer.parseInt(strings[1])));
			}
		} catch (IOException ex) {
			System.out.println("找不到指定文件！！");
		} finally {
			try {
				read.close();
			} catch (IOException ex) {
				System.out.println(ex.getMessage());
			}
		}		
		return mappingList;
		
	}

	
	public static void main(String[] args) {
		mappingReader nfr=new mappingReader();
		List<mapping> mList=nfr.formatRead("mapping.txt");
		for(mapping m:mList){
			System.out.println("======"+m.getiDiskAddress());
		}

	}

}
